# Contributor: River Dillon <oss@outerpassage.net>
# Maintainer: River Dillon <oss@outerpassage.net>
pkgname=alex
pkgver=3.2.6
pkgrel=2
pkgdesc="lexical analyser generator for Haskell"
url="https://www.haskell.org/alex/"
arch="x86_64" # limited by ghc
license="BSD-3-Clause"
makedepends="ghc libffi-dev"
subpackages="$pkgname-doc"
source="
	https://hackage.haskell.org/package/alex-$pkgver/alex-$pkgver.tar.gz
	https://www.haskell.org/alex/doc/alex-doc-html-3.0.tar.gz
	fix-tests-ghc-9.0.patch
	"

build() {
	runhaskell Setup.hs configure \
		"--prefix=/usr" \
		"--datasubdir=$pkgname" \
		"--docdir=\$datadir/doc/$pkgname" \
		"--enable-tests"
	runhaskell Setup.hs build -j "--ghc-options=-j -O1"
}

check() {
	runhaskell Setup.hs test
}

package() {
	docdir="usr/share/doc/$pkgname"
	runhaskell Setup.hs copy "--destdir=$pkgdir"
	rm "$pkgdir/$docdir/LICENSE" # no need to include a standard license
	install -Dm644 -t "$pkgdir/$docdir/html/" "$srcdir/$pkgname"/*
}

sha512sums="
05b6e55e9a1c348aea599d1130780a3d2a0a7c5f1db00b2c98bd34737cac9d48842fb1b1f98947a99d99013f94e39a6ffee1af8546f02fb2d32fcf362ff0f83c  alex-3.2.6.tar.gz
c9497e9b6c80d79d29bd5b1d05cf4077c30c2d94b9c6c321145ca104db204deb96db66f8abba0ad2e849556eda8b901aa6181935e8aca81ff9ffc676d19f87dd  alex-doc-html-3.0.tar.gz
9e8236a3e08add1b2c8ed97da636de900d3f562df2a9dc5496bdf5578908d700c1106cf8ee6b86e4244c02e64b66caa1289b298d66bccc441dae9a3b76dda2d9  fix-tests-ghc-9.0.patch
"
